#include<bits/stdc++.h>
using namespace std;
int a[200000];
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int bs[1234],cnt=0,t=0,n=0;
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int bs[1234]={},cnt=0;
        for(int i=0;i<n;i++){
            if(bs[a[i]]!=0){
                cnt+=a[i];
            }
            bs[a[i]]++;
        }cout<<cnt<<endl;
    }
    return 0;
}
